package com.hc.race.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.race.entity.Challenges;
import com.hc.race.entity.Cu;
import com.hc.race.mapper.ChallengesMapper;
import com.hc.race.service.ChallengeService;
import com.hc.race.service.CuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author zy
 * @Date 2023/11/25 10:00
 * @PackageName:com.hc.race.service.impl
 * @ClassName: ChallengesServiceImpl
 * @Description: TODO
 * @Version 1.0
 */
@Service
public class ChallengesServiceImpl extends ServiceImpl<ChallengesMapper, Challenges> implements ChallengeService {

    @Autowired
    private ChallengesMapper challengesMapper;

    @Autowired
    private CuService cuService;
    @Override
    public List<Challenges> getInfo(Long userId) {
        Cu cu = cuService.getInfo(userId);
        Long challengeId=cu.getTaskId();
        QueryWrapper<Challenges> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",challengeId);
        List<Challenges> challenges = challengesMapper.selectList(queryWrapper);
        return challenges;
    }

    @Override
    public Challenges getSingleInfo(Long challengesId) {
        Challenges challenge = query().eq("id", challengesId).one();
        return challenge;
    }
}
